package rhinestone.Model;
import java.util.GregorianCalendar;
/**
 * Represents a machinery object.
 * Total price = price*(endDate - startDate).
 *
 * @author Group 2
 * @version 2010.12.16
 */
public class Machinery extends Item {
	public static final String AVAILABLE = "Available";
	public static final String ON_LEASE = "On lease";
	private String status;
    private GregorianCalendar startDate;
    private GregorianCalendar endDate;
    private double totalPrice;
	private String location;


	/**
	 * Constructor.
	 *
	 * Parameters I think are self-talking.
	 * @param barcode
	 * @param name
	 * @param description
	 * @param price
	 * @param location
	 */
	public Machinery(String barcode, String name, String description, double price, String location) {
		super(barcode, name, description, price);
		this.status = AVAILABLE;
		this.location = location;
	}

	public double getTotalPrice(int year, int mounth, int day, int year1, int mounth1, int day1){
		startDate.set(year, mounth, day);
		endDate.set(year1, mounth1, day1);
		long period = (endDate.getTimeInMillis() - startDate.getTimeInMillis()) / (1000 * 60 * 60 * 24);
		totalPrice = price * period;
		return totalPrice;
	}

	/**
	 * Getters and setters.
	 */
	public void setStatus(String status) {
		this.status = status;
	}
	public String getStatus() {
		return status;
	}

	public void setLocation(String location) {
		this.location = location;
	}
	public String getLocation() {
		return location;
	}

	/**
	 * Object representation for printing.
	 * No need to call it manually, it is called automatically
	 * whenever you put this object in System.out.println();
	 */
	@Override
	public String toString() {
		String output = "Barcode: " + barcode;
		output += "\nName: " + name;
		output += "\nDescription: " + description;
		output += "\nPrice (1 day lease): " + price;
		output += "\nStatus: " + status;
		if(!status.equals(ON_LEASE))
			output += "\nLocation: " + location;
		return output;
	}
}
